package org.unt.logic;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateLogic {

    public static void main(String[] args) throws IOException {

    	new DateLogic().a();
    	
    	if (true) return;
    	
        java.util.Date utilDate = new java.util.Date();
        long t = utilDate.getTime();

        System.out.println(utilDate);

        System.out.println(dateToString(utilDate));
        System.out.println(dateToString(new java.sql.Date(t)));

    }

    void a() {
    	
    	SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
    	System.out.println(sdf.format(new Date()));
    }
    
    public static java.util.Date fromSqlToUtilDate(java.sql.Date sqlDate) {

        long t = sqlDate.getTime();
        return new java.util.Date(t);
    }

    public static java.sql.Date fromUtilToSqlDate(java.util.Date utilDate) {

        long t = utilDate.getTime();
        return new java.sql.Date(t);
    }

    public static String dateToString(java.util.Date utilDate) {

        if (utilDate == null) {
            return null;
        }

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(utilDate);
    }

}
